package br.com.caelum.vraptor.dao;

import javax.persistence.NoResultException;

import br.com.caelum.vraptor.entidades.Administrador;
import br.com.caelum.vraptor.entidades.Usuario;

public class AdministradorDAO extends GenericJPADAO<Administrador>{
	
	public AdministradorDAO() {
		this.persistentClass = Administrador.class;
	}
	
	public Administrador find(String login, String senha){
		try{
		return getEm().createQuery("select u from Administrador u where u.login= :login and u.senha=:senha", Administrador.class)
				.setParameter("login", login)
				.setParameter("senha", senha)
				.getSingleResult();
		}
		catch(NoResultException e){
			e.printStackTrace();
			return null;
		}
	}
}
